

import pandas as pd

from sqlalchemy import create_engine


def model(dbt, session):
    # my_sql_model_df = dbt.ref("my_first_dbt_model") # 可以从model中提取数据
    # final_df =  my_sql_model_df # stuff you can't write in SQL!
    li = []
    for line in ['手机周边','乐器用品','家居园艺','影视摄影','仪器仪表','工艺收藏','手表首饰','汽摩用品','电子用品','母婴用品',
            '电脑用品','工业用品','宠物用品','户外用品','服装服饰','智能安防','健康美容','消费电子']:
        path = r"E:\TemParquet\ProductSystem\product_info\product_system*.parquet"
        sql = f'''
                select sku,line1
                from read_parquet(['{path}'])
                where line1 = '{line}' and develop_source = '泛品铺货' and product_status = '在售中'
                and end_time::datetime > '2024-01-01'
                limit 10
                '''
        df_x = session.execute(sql).df()
        li.append(df_x)
    final_df = pd.concat(li)
      
        

    # final_df = pd.read_excel(r"C:\Users\Administrator\Desktop\AI文案标题重复是与否--评测.xlsx")
    

    print(f"我是:{dbt.config.get('materialized')}")
    # print(f"我是:{dbt.config.get('tags')}")
    # print(f"我是:{dbt.config.get('remote_warehouse')}")

    

    # 筛选出30天内的数据
    return final_df



